package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.AuditFlow;
import com.zygh.policeasset.pojo.HelpContent;
import com.zygh.policeasset.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HelpContentMapper {

    @Select({"<script>" +
            "select * from help_content " +
            "<where> " +
            "<if test='title != null '>title like concat('%',#{title},'%') </if>" +
            "</where> " +
            "</script> "})
    List<HelpContent> findAllByTitle(@Param("title") String title);

    @Insert({"insert into help_content (title,content) values (#{title},#{content})"})
    Integer add(HelpContent helpContent);

    @Update({"<script>" +
            "update help_content " +
            "<set>" +
            "<if test='title != null and title.length &gt; 0'>title=#{title},</if>" +
            "<if test='content != null and content.length &gt; 0'>content=#{content},</if>" +
            "</set>" +
            "where " +
            "id=#{id}" +
            "</script>"})
    Integer update(HelpContent helpContent);

    @Delete({"delete from help_content where id=#{id}"})
    Integer delete(Integer id);

    @Select({" select * from help_content where id = #{id} "})
    HelpContent findById(@Param("id") Integer id);
}